<?php

require("top.ajax.php");

if(isset($_POST['a']) && $_POST['a'] == "update") {
    
    $widget = new Widget($_POST['u']);

    foreach($_POST as $key => $val) {
        if($key != "a" && $key != "u") {
            if($key == "addProduct") {
                $widget->addProduct($val);
            } elseif($key == "delProduct") {
                $widget->delProduct($val);
            } elseif($key == "site") {
                $widget['user']['site'] = $val;
                $widget['user']->save();
            } elseif($key == "descr-site") {
                $widget['user']['descr-site'] = $val;
                $widget['user']->save();
            } else {
                $widget->setValue($key, $val);
            }
        }
    }
}

?>
